<?php
declare (strict_types=1);

namespace app\exam\model\admin;

use app\common\model\BaseModel;

/**
 * Class ModuleRollup
 *
 * @package app\exam\model\admin
 */
class ModuleRollupPaper extends BaseModel
{
    /**
     * 表名
     *
     * @var string
     */
    protected $name = 'exam_module_rollup_paper';
    /**
     * 自动写入时间
     *
     * @var bool
     */
    protected $autoWriteTimestamp = true;

    /**
     * 定义表主键
     *
     * @var string
     */
    protected $pk = 'id';
    /**
     * 时间显示格式
     *
     * @var string
     */
    protected $dateFormat = 'Y-m-d H:i';

    /**
     * 关联试卷信息
     * Author: Martinsun <syh@sunyonghong.com>
     * Date: 2021/3/2
     *
     * @return \think\model\relation\BelongsTo
     */
    public function paper()
    {
        return $this
            ->belongsTo(Paper::class, 'paper_id', 'id')
            ->append(['paper_type_text'])
            ->bind(['title', 'topic_count' => 'total_count', 'paper_type', 'paper_type_text', 'category', 'total_score']);
    }
}